<template>
	<div class="main-content">
		<form id="frm">
			<div class="information-form">
				<h3>楼盘基本信息<a v-on:click="chooseM2Premises" v-if="m2Flag == 'T'" target="_blank" style="color: cornflowerblue;font-weight: normal;padding-left: 20px;">从M2系统同步楼盘</a></h3>
				<ul class="housing-list">
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">楼盘名称:</label>
							<div class="control-details">
								<input type="text" class="form-control" style="width:50%;" placeholder="楼盘名称" v-model="premises.name" v-on:blur="verifyingPremisesName">
								<span style="color:#ff0000;padding-left:5px;word-wrap:break-word !important;white-space: initial !important; " v-if="premisesNames">已存在同名楼盘：{{premisesNames}}，请修改</span>
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">省份市区:</label>
							<div class="control-details">
								<select class="form-control" style="width:25%;float:left" v-model="premises.provinceId" id="provinceId" v-on:change="getCity()">
									<option v-for="(province,index) in province_list" :value="province.id" :key="index">{{province.name}}</option>
								</select>
								<span style="float:left">-</span>
								<select class="form-control" style="width:25%;float:left" v-model="premises.cityId" id="city" v-on:change="getArea()">
									<option v-for="(city,index) in city_list" :value="city.id" :key="index">{{city.name}}</option>
								</select>
								<span style="float:left">-</span>
								<select class="form-control" style="width:25%;float:left" v-model="premises.areaId">
									<option v-for="(area,index) in area_list" :value="area.id" :key="index">{{area.name}}</option>
								</select>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="estateType">物业类型:</label>
							<div class="col-xs-2 user-define">
								<select id="estateType" style="width:209px" multiple="multiple">
									<option v-for="(value,index) in estate_list" :value="index" :key="index">{{value}}</option>
								</select>
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="buildingType">建筑类别:</label>
							<div class="col-xs-2 user-define">
								<select id="buildingType" style="width:209px" multiple="multiple">
									<option v-for="(value,index) in buildingType_list" :value="index" :key="index">{{value}}</option>
								</select>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">结佣方式:</label>
							<div class="control-details">
								<select class="form-control" style="width:50%" v-model="premises.commissionWay">
									<option value="1">签约结佣</option>
									<option value="2">按揭结佣</option>
									<option value="3">首付交齐</option>
                                    <option value="4">全款到账</option>
								</select>
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">装修状况:</label>
							<div class="control-details">
								<select class="form-control" style="width:50%" v-model="premises.decorationType">
									<option v-for="(row,index) in decoration_list" v-bind:value="index" :key="index">{{row}}</option>
								</select>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for=""><!---->开盘日期:</label>
							<div style="padding-left:20px; text-overflow:ellipsis;position: relative;">
								<DatePicker type="date" placeholder="开盘日期" v-model="premises.openingTime"></DatePicker>

							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for=""><!---->入住日期:</label>
							<div style="padding-left:20px; text-overflow:ellipsis;position: relative;">
								<DatePicker type="date" placeholder="入住日期" v-model="premises.checkInTime"></DatePicker>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">均价:</label>
							<div style="width:25%;display:inline;float: left;text-align: center" >
								<InputNumber  :min="0"    v-model="beginPrice" size="small"  ></InputNumber>
								<span style="padding-left:20px">&nbsp;至</span>
							</div>

							<div style="width:25%;display:inline;float: left" >
								<InputNumber :min="0"  v-model="endPrice" size="small" />&nbsp;元/㎡
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">物业费:</label>
							<div class="control-details">
								<input type="text" class="form-control" style="width:50%;display:inline" placeholder="物业费" v-model="premises.propertyCharges">&nbsp;元/㎡/月
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">容积率:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" placeholder="容积率" v-model="premises.plotRatio">&nbsp;
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">绿化率:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" placeholder="绿化率" v-model="premises.greeningRate">&nbsp;%
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">物业公司:</label>
							<div class="control-details">
								<input type="text" class="form-control" style="width:50%" placeholder="物业公司" v-model="premises.propertyCompany">
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="baseCodeValue">&nbsp;楼盘标签:</label>
							<div class="col-xs-2 user-define">
								<select id="baseCodeValue" style="width:209px" multiple="multiple">
									<option v-for="(row,index) in baseCodeValueList" :value="row.id" :key="index">{{row.codeName}}</option>
								</select>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">物业地址:</label>
							<div class="control-details">
								<input type="text" class="form-control" style="width:50%;" placeholder="物业地址" v-model="premises.propertyAddr">
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">开发商:</label>
							<div class="control-details">
								<input type="text" class="form-control" style="width:50%;" placeholder="开发商" v-model="premises.buildingCompany">
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">在售状态:</label>
							<div class="control-details">
								<select class="form-control" style="width:50%" v-model="premises.saleStatus">
									<option value="0">待售</option>
									<option value="1">在售</option>
									<option value="2">售罄</option>
								</select>
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">售楼部地址:</label>
							<div class="control-details">
								<input type="text" class="form-control" style="width:50%;" placeholder="售楼部地址" v-model="premises.saleAddr">
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">产权年限:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" placeholder="产权年限" v-model="premises.rightYears">&nbsp;年
							</div>
						</div>
						<!--<div class="list-info-template col-md-6">-->
							<!--<label class="control-label" for="">排序:</label>-->
							<!--<div class="control-details">-->
								<!--<input type="number" class="form-control" style="width:50%;display:inline" placeholder="排序" v-model="premises.sequence" title="按从小到大依次排列，请使用整数否则无效" />-->
							<!--</div>-->
						<!--</div>-->
						<div class="list-info-template col-md-6">
							<label class="control-label">规划户数:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" placeholder="规划户数" v-model="premises.houseHolds" />
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label">地上车位数:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" placeholder="地上车位数" v-model="premises.upCarPort">
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label">地下车位数:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" placeholder="地下车位数" v-model="premises.downCarPort" />
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">楼盘地址:</label>
							<div class="control-details">
								<textarea v-model="premises.premisesAddress" style="width: 400px;height: 66px;"></textarea>
							</div>
						</div>

					</li>
				</ul>
			</div>
			<div class="information-form">
				<h3>分销信息</h3>
				<ul class="housing-list">
					<li style="height: 130px;">
						<div class="list-info-template">
							<label class="control-label" for="">分销佣金:</label>
							<div style="margin-left: 20px; color:gray; word-wrap:break-word">
								*此处分销佣金只作为对分销商的展示所用,具体分销结佣的佣金设置请在佣金管理中进行设定
							</div>
							<div v-for="(item, index) in commissionList" :key="index" class="control-button-wrap">
								<div class="control-button-wrap-content">
									<div class="delete-commission" @click="delCommission(index)">×</div>
									<span>{{item.name}}</span> : <span>{{item.typeValue}}{{item.type}}</span>
								</div>
							</div>
							<div class="control-button-add" @click="showModal" style="margin-left: 20px; margin-top: 5px;"><span style="font-size: 20px;">+</span>&nbsp;添加</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">带看奖励:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" placeholder="带看奖励" v-model="premises.reward">&nbsp;元
							</div>
						</div>
						<div class="list-info-template col-md-6" style="padding-left: 140px">
							<div class="" style="float:left; text-align: right;position: absolute;left: 0;   top: 0;   width: 140px;">
								<RadioGroup v-model="dealType">
									<Radio label="成交奖"></Radio>
									<Radio label="现金奖"></Radio>
								</RadioGroup>
							</div>
							<div class="control-details col-md-8">
								<input type="number" class="form-control" style="width:50%;display:inline" v-bind:placeholder="dealType" v-model="premises.dealAward">&nbsp;元
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="" style="width:100px">最短报备时间:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" placeholder="最短报备时间" v-model="premises.specialTime">&nbsp;分钟
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="" style="width:100px">报备保护时间:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" placeholder="报备保护时间" v-model="premises.visitProtect">
								<div class="" style="float:right">
									<RadioGroup v-model="visitProtectType">
										<Radio label="天"></Radio>
										<Radio label="分钟"></Radio>
									</RadioGroup>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">带看保护时间:</label>
							<div class="control-details">
								<input type="number" class="form-control" style="width:50%;display:inline" v-model="premises.saveDays">&nbsp;天
							</div>
							<div style="padding:0;color:#f00;word-wrap:break-word">
								《报备已到访，过了设置的天数未认筹、认购、签约，报备自动转为无效，不填默认为7天》
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">合作有效期:</label>
							<table width="51%" border="0">
								<tr>
									<td width="48%">
										<div style="padding-left:20px; text-overflow:ellipsis;position: relative;">
											<DatePicker type="date" placeholder="合作开始时间" v-model="premises.cooperationBeginTime"></DatePicker>
										</div>
									</td>
									<td width="4%">至</td>
									<td width="48%">
										<div style="text-overflow:ellipsis;position: relative;">
											<DatePicker type="date" placeholder="合作结束时间" v-model="premises.cooperationEndTime"></DatePicker>
										</div>
									</td>
								</tr>
							</table>
						</div>
					</li>
					<li>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">项目经理:</label>
							<div class="control-details">
								<input type="text" class="form-control" style="width:50%;" placeholder="项目经理" v-model="premises.manager">
							</div>
						</div>
						<div class="list-info-template col-md-6">
							<label class="control-label" for="">联系方式:</label>
							<div class="control-details">
								<input type="text" class="form-control" style="width:50%;" placeholder="联系方式" v-model="premises.mobile" v-on:blur="verifyingMobile">
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template" style="width:78%">
							<label class="control-label" for="">促销信息:</label>
							<div class="control-details" style="height: 270px;">
								<quill-editor  id="discount" v-model="premises.discount" :options="editorOption"></quill-editor>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template" style="width:78%">
							<label class="control-label" for="">项目特色:</label>
							<div class="control-details" style="height: 270px;">
								<quill-editor  id="feature" v-model="premises.feature" :options="editorOption"></quill-editor>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template" style="width:78%">
							<label class="control-label" for="">合作规则:</label>
							<div class="control-details" style="height: 270px;">
								<quill-editor  id="cooperationRule" v-model="premises.cooperationRule" :options="editorOption"></quill-editor>
							</div>
						</div>
					</li>
				</ul>
			</div>

			<div class="information-form">
				<h3>楼盘相册</h3>
				<ul class="nav nav-tabs" style="margin: 15px">
					<li class="presentation" role="presentation" id="p3">
						<a href="#3" data-toggle="tab">样板间({{showImgCount(premisesImages[3])}})</a>
					</li>
					<li class="presentation" role="presentation" id="p4">
						<a href="#4" data-toggle="tab">效果图({{showImgCount(premisesImages[4])}})</a>
					</li>
					<li class="presentation" role="presentation" id="p5">
						<a href="#5" data-toggle="tab">小区配套({{showImgCount(premisesImages[5])}})</a>
					</li>
					<li class="presentation" role="presentation" id="p6">
						<a href="#6" data-toggle="tab">实景图({{showImgCount(premisesImages[6])}})</a>
					</li>
					<li class="presentation" role="presentation" id="p7">
						<a href="#7" data-toggle="tab">项目现场({{showImgCount(premisesImages[7])}})</a>
					</li>
					<li class="presentation" role="presentation"><input type="button" value="上传" class="btn checkedBtn" style="width: 90px;" @click="openUploadImage"></li>
				</ul>
				<div class="tab-content panel-body" style="margin: 15px;min-height: 110px;">
					<div class="tab-pane fade in " :class="{active:row==3}" :id="row" v-for="(row,index) in premisesTypes" :key="index">
						<ul class="premises-image-list">
							<li class="col-md-2" v-for="(img, i) in premisesImages[row]" :key="i">
								<img v-bind:src="img.imageUrl" width="100px" height="80px;" />
								<i class="fa fa-times-circle" @click="deletePremisesImage(i,img,row)"></i>
							</li>
						</ul>
					</div>
				</div>
			</div>

			<div class="information-form">
				<h3>公司信息</h3>
				<ul class="housing-list">
					<li>
						<div class="list-info-template">
							<label class="control-label">公司名称:</label>
							<div class="control-details">
								<input type="text" class="form-control" style="width:30%" placeholder="公司名称" v-model="premises.corporateName">
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template" style="width:78%">
							<label class="control-label" for="">公司简介:</label>
							<div class="control-details" style="height: 270px;">
								<quill-editor  id="corporateDesc" v-model="premises.corporateDesc" :options="editorOption"></quill-editor>
							</div>
						</div>
					</li>

					<li>
						<table width="78%" border="0">
							<tr>
								<td>
									<div class="list-info-template col-md-6">
										<label class="control-label" for="">证照资料:</label>
									</div>
								</td>
							</tr>
							<tr>
								<td style="padding-left: 12%;">
									<ul id="myTab" class="nav nav-tabs">
										<li class="active">
											<a href="#zhizhao" data-toggle="tab">营业执照</a>
										</li>
										<li>
											<a href="#hetong" data-toggle="tab">分销合同</a>
										</li>
										<li>
											<a href="#xukezheng" data-toggle="tab">预售许可证</a>
										</li>
										<li>
											<a href="#shouquanshu" data-toggle="tab">开发商授权书</a>
										</li>
									</ul>
									<div id="myTabContent" class="tab-content">
										<div class="tab-pane fade in active" id="zhizhao">

											<li class="col-md-2 file-image" v-for="(row,index) in licenseList" :key="index" v-if="row.isDeleted==0 && row.imageType==60" style="margin-left: 30px;">
												<img v-bind:src="row.imageUrl" width="150px" height="115px" />
												<i class="fa fa-times-circle" @click="removeImage(row)"></i>
											</li>

											<li class="col-md-2 file-image" style="margin-left: 30px;">
												<div class="file-upload">
													<input ref="businessLicense" type="file" class="file-btn" style="width:100%;" @change="onFileChange" alt="60">
													<i class="layui-icon"></i>
													<p>添加营业执照</p>
												</div>
											</li>

										</div>
										<div class="tab-pane fade " id="hetong">
											<li class="col-md-2 file-image" v-for="(row,index) in licenseList" :key="index" v-if="row.isDeleted==0 && row.imageType==70" style="margin-left: 30px;">
												<img v-bind:src="row.imageUrl" width="150px" height="115px" />
												<i class="fa fa-times-circle" @click="removeImage(row)"></i>
											</li>

											<li class="col-md-2 file-image" style="margin-left: 30px;">
												<div class="file-upload">
													<input ref="distributorContract" type="file" class="file-btn" style="width:100%; " @change="onFileChange" alt="70">
													<i class="layui-icon"></i>
													<p>添加分销合同</p>
												</div>
											</li>
										</div>

										<div class="tab-pane fade" id="xukezheng">

											<li class="col-md-2 file-image" v-for="(row,index) in licenseList" :key="index" v-if="row.isDeleted==0 && row.imageType==80" style="margin-left: 30px;">
												<img v-bind:src="row.imageUrl" width="150px" height="115px" />
												<i class="fa fa-times-circle" @click="removeImage(row)"></i>
											</li>

											<li class="col-md-2 file-image" style="margin-left: 30px;">
												<div class="file-upload">
													<input ref="salePermit" type="file" class="file-btn" style="width:100%; " @change="onFileChange" alt="80">
													<i class="layui-icon"></i>
													<p>添加预售许可证</p>
												</div>
											</li>
										</div>

										<div class="tab-pane fade" id="shouquanshu">
											<li class="col-md-2 file-image" v-for="(row,index) in licenseList" :key="index" v-if="row.isDeleted==0 && row.imageType==90" style="margin-left: 30px;">
												<img v-bind:src="row.imageUrl" width="150px" height="115px" />
												<i class="fa fa-times-circle" @click="removeImage(row)"></i>
											</li>

											<li class="col-md-2 file-image" style="margin-left: 30px;">
												<div class="file-upload">
													<input ref="warrant" type="file" class="file-btn" style="width:100%; " @change="onFileChange" alt="90">
													<i class="layui-icon"></i>
													<p>添加开发商授权书</p>
												</div>
											</li>
										</div>
									</div>
								</td>
							</tr>
						</table>
					</li>
				</ul>
			</div>

			<div class="information-form">
				<h3>其他信息</h3>
				<ul class="housing-list">
					<li>
						<div class="list-info-template" style="width:78%">
							<label class="control-label" for="">楼盘卖点:</label>
							<div class="control-details" style="height: 260px;">
								<quill-editor id="selling" v-model="premises.selling" :options="editorOption"></quill-editor>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template" style="width:78%">
							<label class="control-label" for="">目标客户:</label>
							<div class="control-details" style="height: 260px;">
								<quill-editor id="customer" v-model="premises.customer" :options="editorOption"></quill-editor>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template" style="width:78%">
							<label class="control-label" for="">拓客技巧:</label>
							<div class="control-details" style="height: 260px;">
								<quill-editor id="saleSkill" v-model="premises.saleSkill" :options="editorOption"></quill-editor>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template" style="width:78%">
							<label class="control-label" for="">项目介绍:</label>
							<div class="control-details" style="height: 260px;">
								<quill-editor id="introduction" v-model="premises.introduction" :options="editorOption"></quill-editor>
							</div>
						</div>
					</li>
					<li>
						<div class="list-info-template" style="width:78%">
							<label class="control-label" for="">报备模板:</label>
							<div class="control-details">
								<textarea id="reportTemp" v-model="premises.reportTemp" rows="3" style="width: 100%"></textarea>
							</div>
						</div>
					</li>
					<li>
						<table width="78%" border="0">
							<tr>
								<td>
									<div class="list-info-template col-md-6">
										<label class="control-label" for="">可售户型:</label>
										<div class="control-details">
											<input type="button" class="form-control" style="width:110px" @click="uploadHouseType" value="上传可售户型">
										</div>
									</div>
								</td>
							</tr>
							<tr>
								<td style="padding-left: 8%;">
									<ul id="houseTypeImg">
										<li class="col-md-2" v-for="(row, index) in houseTypeList" :key="index">
											<img v-bind:src="row.url" width="100px" height="80px;" />
											<i class="fa fa-times-circle" @click="deletefile(index)"></i>
											<p style="width:130px">{{row.apartmentLayout}}&nbsp;{{row.area}}平米</p>
										</li>
									</ul>
								</td>
							</tr>
						</table>
					</li>
					<li>
						<table width="51%" border="0">
							<tr>
								<td>
									<div class="list-info-template" style="width:55%;">
										<label class="control-label" for="">封面图片地址:</label>

									</div>
								</td>
							</tr>
							<tr>
								<td style="padding-left: 8%;">
									<ul>
										<li class="col-md-2" style="margin-left: 50px;">
											<img v-if="premises.url!=null && premises.url!=''" v-bind:src="premises.url" width="150px" height="120px;" />
										</li>
										<li style="margin-left: 200px;">

											<div class="add-huxing">
												<input type="file" class="file-btn" style="width:100%; " @change="onFileChange">
												<i class="layui-icon"></i>
												<p>添加封面图</p>
											</div>
										</li>
									</ul>
								</td>
							</tr>
						</table>
					</li>
					<li>
						<div class="list-info-template col-sm-6">
							<label class="control-label" for="">全景看房:</label>
							<div class="control-text">
								<input type="text" class="form-control" style="width:50%;" placeholder="全景看房地址" v-model="premises.panoramicView">
								<a v-bind:href="premises.panoramicView" v-if="premises.panoramicView" target="_blank" style="color: cornflowerblue">
									点击查看
								</a>
							</div>
						</div>
					</li>
				</ul>
				<div class="list-info-template col-sm-10" style="padding-top:20px;padding-bottom:20px;text-align:center;">
					<input type="button" class="btn checkedBtn" v-show="btnShow" style="width:110px" @click="savePremises" value="保存">
					<button type="button" class="btn btn-default" style="margin-left:20px;width:110px" @click="goBack">返回</button>
				</div>
			</div>
		</form>

		<!-- 弹出层 -->
		<div id="fade" class="black_overlay"></div>
		<div id="mydiv" class="white_content">
			<div class="white_content_header">
				<span class="white_content_title">添加分销佣金</span>
				<span class="white_content_close" @click="closeModal">×</span>
			</div>
			<div class="first_white_input">
				<label class="set_format" for="">方案名称&nbsp;&nbsp;</label>
				<input id="set_format_id" type="text" class="set_format_input" style="display:inline-block; width: 195px" placeholder="方案名称">
			</div>
			<div class="first_white_input">
				<label class="set_money" for="">设置佣金&nbsp;&nbsp;</label>
				<input id="set_money_id" type="number" step="0.01" class="set_money_input" style="display:inline-block; width: 140px" placeholder="设置佣金">
				<div class="select_type">
					<div id="type_money" @click="typeChange('1')" :class="{'check_type': checkedMoney, 'check_type1': checkedPercent}">元</div>
					<div id="type_percent" @click="typeChange('2')" :class="{'check_type': checkedPercent, 'check_type1': checkedMoney}">%</div>
				</div>
			</div>
			<div class="first_white_button" @click="addCommission">
				确定
			</div>
		</div>
		<addUploadModal v-on:saveUploadListener='saveUploadReturn' v-bind:decoration="decoration_list"></addUploadModal>
		<addChooseM2 v-bind:chooseM2Modal="premisesByM2Flag" v-on:saveChooseM2Listener='saveChooseM2Return'></addChooseM2>
		<addPremisesImageModal v-on:saveUploadPremisesImageListener="savePremisesImgReturn" ref="premisesImageInit"></addPremisesImageModal>
		<input type="file" id="iviewUp" @change="textImageUpload" style="display: none" />
	</div>
</template>
<style>
	@import url("../../assets/css/multiple-select.css");
	#discount,
	#feature,
	#cooperationRule,
	#selling,
	#customer,
	#saleSkill,
	#introduction {
		height: 200px;
	}
	
	.user-define li {
		padding: 0px;
		margin: 0px;
	}
	
	.control-button-wrap {
		display: inline-block;
		height: 38px;
		border-radius: 3px;
		margin-left: 22px;
		/* position: relative;
	top: -10px; */
	}
	
	.add-huxing {
		width: 150px;
		height: 115px;
		position: relative;
		padding: 30px;
		border: 1px dashed #e2e2e2;
		background-color: #fff;
		text-align: center;
		cursor: pointer;
		color: #999;
		display: inline-block;
	}
	
	.add-huxing .layui-icon {
		font-size: 50px;
		color: #f87142;
	}
	
	.white_content_header {
		width: 100%;
		height: 40px;
		line-height: 40px;
		background: rgba(248, 248, 248, 1);
		border-bottom: 1px solid #d3d3d3;
	}
	
	.control-button-wrap-content {
		min-width: 120px;
		min-height: 38px;
		line-height: 38px;
		border-radius: 3px;
		text-align: center;
		color: #999;
		border: 1px solid #d3d3d3;
		margin-top: 10px;
		position: relative;
		top: -10px;
	}
	
	.control-button-wrap-content .delete-commission {
		width: 10px;
		height: 10px;
		line-height: 10px;
		font-size: 10px;
		border-radius: 50%;
		border: 1px solid #F87242;
		color: #F87242;
		cursor: pointer;
		float: right;
	}
	
	.control-button-add {
		display: inline-block;
		width: 70px;
		height: 38px;
		line-height: 38px;
		text-align: center;
		border: 1px dashed #ccc;
		border-radius: 5px;
		color: #999;
		cursor: pointer;
		position: relative;
		top: -7px;
		margin-left: 5px;
	}
	
	.black_overlay {
		display: none;
		position: absolute;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: black;
		z-index: 1001;
		-moz-opacity: 0.8;
		opacity: .50;
		filter: alpha(opacity=50);
	}
	
	.white_content {
		display: none;
		position: absolute;
		top: 20%;
		left: 36%;
		width: 333px;
		height: 211px;
		border: 2px solid #d3d3d3;
		background-color: white;
		z-index: 1002;
		/* overflow: auto; */
		border-radius: 5px;
	}
	
	.white_content_title {
		color: #F87242;
		font-weight: 700;
		margin-left: 20px;
		font-size: 14px;
	}
	
	.white_content_close {
		float: right;
		margin: 10px 10px 0 0;
		width: 20px;
		height: 20px;
		line-height: 20px;
		text-align: center;
		color: #999;
		font-size: 29px;
		border: 1px solid #d3d3d3;
		cursor: pointer;
	}
	
	.first_white_input {
		width: 80%;
		margin: 10px auto 20px;
	}
	
	.first_white_input .set_format,
	.set_money {
		color: #333;
		font-size: 14px;
	}
	
	.first_white_input input {
		height: 32px;
		border-radius: 3px;
		outline: 0;
		border: 1px solid #999;
	}
	
	.first_white_input input:focus {
		border: 1px solid #F87242
	}
	
	.select_type {
		width: 50px;
		height: 32px;
		float: right;
		border-radius: 5px;
		display: flex;
		flex-direction: row;
		cursor: pointer;
	}
	
	.select_type #type_money {
		width: 25px;
		height: 32px;
		line-height: 32px;
		/* background: #F87242; */
		color: #fff;
		border-top-left-radius: 5px;
		border-bottom-left-radius: 5px;
		text-align: center;
	}
	
	.select_type #type_percent {
		width: 25px;
		height: 32px;
		line-height: 32px;
		text-align: center;
		/* background: #d3d3d3; */
		color: #fff;
		border-top-right-radius: 5px;
		border-bottom-right-radius: 5px;
	}
	
	.set_money_input::-webkit-outer-spin-button,
	.set_money_input::-webkit-inner-spin-button {
		-webkit-appearance: none;
	}
	
	.set_money_input[type="number"] {
		-moz-appearance: textfield;
	}
	
	.check_type {
		background: #F87242;
	}
	
	.check_type1 {
		background: #d3d3d3;
	}
	
	.first_white_button {
		background: #F87242;
		color: #fff;
		width: 83px;
		height: 32px;
		line-height: 32px;
		text-align: center;
		font-size: 16px;
		border-radius: 3px;
		float: right;
		margin-right: 30px;
		cursor: pointer;
	}
	
	.file-upload {
		width: 150px;
		height: 115px;
		position: relative;
		padding: 30px;
		border: 1px dashed #e2e2e2;
		background-color: #fff;
		text-align: center;
		cursor: pointer;
		color: #999;
		display: inline-block;
	}
	
	.file-upload:hover {
		border: 1px dashed #f87142;
	}
	
	.file-btn {
		position: absolute;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		outline: none;
		background-color: transparent;
		filter: alpha(opacity=0);
		-moz-opacity: 0;
		-khtml-opacity: 0;
		opacity: 0;
		cursor: pointer;
		z-index: 0;
	}
	
	.file-upload .layui-icon {
		font-size: 50px;
		color: #f87142;
	}
	
	#myTab li {
		padding: 0;
	}
</style>
<script>
	import swiper from '../../assets/js/multiple-select.js'
	import calendar from "../common/calendar.vue"
	import viewer from '../../assets/js/viewer.js'
	import addUploadModal from './premisesUpload.vue'
	import addChooseM2 from './premisesChooseM2.vue'
	import addPremisesImageModal from './addPremisesImage.vue'
    const toolbarOptions = [
        ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
        ['blockquote', 'code-block'],

        [{'header': 1}, {'header': 2}],               // custom button values
        [{'list': 'ordered'}, {'list': 'bullet'}],
        [{'script': 'sub'}, {'script': 'super'}],      // superscript/subscript
        [{'indent': '-1'}, {'indent': '+1'}],          // outdent/indent
        [{'direction': 'rtl'}],                         // text direction

        [{'size': ['small', false, 'large', 'huge']}],  // custom dropdown
        [{'header': [1, 2, 3, 4, 5, 6, false]}],

        [{'color': []}, {'background': []}],          // dropdown with defaults from theme
        [{'font': []}],
        [{'align': []}],
        ['link', 'image', 'video'],
        ['clean']                                         // remove formatting button
    ]
	export default {
		data() {
            let _self = this;
			return {
                quill:'',
                editorOption: {
                    placeholder: '请输入内容',
                    theme: 'snow',  // or 'bubble'
                    modules:{
                        toolbar:{
                            container: toolbarOptions,  // 工具栏
                            handlers: {
                                // handlers object will be merged with default handlers object
                                image: function (value,e) {
                                    if (value) {
                                        document.getElementById('iviewUp').click()
                                        _self.quill = this.quill;
                                    } else {

                                    }
                                }
                            }
                        }
                    },

                },
				premises: {
					saleStatus: 1,
					commissionWay: 1,
					name: '',
					urlBase64: '', //初始化封面图片
					url:''
				},
				province_list: [],
				baseCodeValueList: [],
				buildingType_list: [],
				city_list: [],
				area_list: [],
				estate_list: [],
				decoration_list: [],
				houseTypeList: [],
				commissionRadio: '1',
				disabledAmount: false,
				disabledRate: true,
				btnShow: true,
				imgUrl: '',
				mobileFlag: true,
				m2Flag: '',
				agentshow: false,
				m2Premises: {
					projectCode: '',
					projectName: '',
				},
				//该字段为弹出框的监听值，用于启动初始化查询
				premisesByM2Flag: '',
				dealType: '成交奖',
				checkedMoney: true,
				checkedPercent: false,
				commissionList: [],

				huxing: {},
				houseEditList: [],
				premisesImages: [],
				editPremisesImgs: [],
				premisesTypes: [3, 4, 5, 6, 7],
				visitProtectType: '天',
				premisesImageInit: [],
				licenseList: [],
                beginPrice:'',
				endPrice:'',
				premisesNames: '', //重复楼盘
				repeatPremisesNameFlag: false
			}
		},
		mounted: function() {
			//初始化
			this.provinceList();
			this.enumList();
			this.getChooseM2PremisesFlag();
			this.getBaseCodeValueList();
		},
		components: {
            calendar,
			//VueEditor,
			addUploadModal,
			addChooseM2,
			addPremisesImageModal
		},
		methods: {
			showModal: function() {
				let scrollHeight = document.body.scrollHeight; //文档高度
				document.getElementById('fade').style.height = scrollHeight + 'px'
				document.getElementById('mydiv').style.display = 'block'
				document.getElementById('fade').style.display = 'block'
				document.getElementById('set_format_id').value = ''
				document.getElementById('set_money_id').value = ''
				this.checkedMoney = true
				this.checkedPercent = false
			},
			removeImage: function(row) {
				var _self = this;
				_self.licenseList.splice(row, 1);
				// var index = _self.licenseList.indexOf(row);
				// _self.licenseList[index].isDeleted = 1;
			},
			closeModal: function() {
				document.getElementById("mydiv").style.display = 'none'
				document.getElementById("fade").style.display = 'none'
			},
			typeChange: function(val) {
				let money = document.getElementById('set_money_id')
				let value = money.value
				if(val === '1') {
					this.checkedMoney = true
					this.checkedPercent = false
				} else {
					this.checkedMoney = false
					this.checkedPercent = true
				}
			},
			addCommission: function() {
				var _self = this;
				if(_self.verificationCommission()) {
					let format = document.getElementById('set_format_id')
					let money = document.getElementById('set_money_id')
					if(format.value && money.value) {
						let newArr = []
						if(_self.checkedMoney) {
							newArr[0] = {
								name: format.value,
								typeValue: money.value,
								type: "元"
							}
							_self.commissionList.push(newArr[0])
						} else {
							newArr[0] = {
								name: format.value,
								typeValue: money.value,
								type: "%"
							}
							_self.commissionList.push(newArr[0])
						}
						document.getElementById("mydiv").style.display = 'none'
						document.getElementById("fade").style.display = 'none'
					}
				}
			},
			delCommission: function(index) {
				this.commissionList.splice(index, 1);
			},
			//初始化多选下拉框
			initMultiple() {
				$("#buildingType").multipleSelect({
					filter: true,
					selectAllText: "全选"
				});
				$("#estateType").multipleSelect({
					filter: true,
					selectAllText: "全选"
				});
			},
			getBaseCodeValueList() {
				//获取楼盘标签
				var _self = this;
				var body = {};
				body.params = {};
				var url = _self.utilHelper.apiUrl + '/api/getBaseCodeValueList';
				_self.$http.post(url, body).then((response) => {
					var resData = response.body.resData;
					if(resData.result == '1') {
						_self.baseCodeValueList = resData.baseCodeValueList;
					}
					_self.$nextTick(() => {
						$("#baseCodeValue").multipleSelect({
							filter: true,
							selectAllText: "全选",
							minimumCountSelected: 10
						});
					});
				});
			},
			getChooseM2PremisesFlag() {
				var _self = this;
				var body = {};
				body.params = {};
				var url = _self.utilHelper.apiUrl + '/api/getChooseM2PremisesFlag.do';
				_self.$http.post(url, body).then((response) => {
					var resData = response.body;
					if(resData.result == "1") {
						_self.m2Flag = resData.resData.m2Flag;
					}
				});
			},
			provinceList: function() {
				var _self = this;
				var body = {};
				body.params = {};
				var url = _self.utilHelper.apiUrl + '/api/getProvince.do';
				_self.$http.post(url, body).then((response) => {
					var resData = response.body.resData;
					_self.province_list = resData.areaList;
				});
			},
			getCity: function() {
				var _self = this;
				var provinceId = $('#province').val();
				if(!provinceId || provinceId == "0") {
					provinceId = _self.premises.provinceId;
				}
				var body = {};
				body.params = {
					areaId: provinceId
				};
				var url = _self.utilHelper.apiUrl + '/api/getCity.do';
				_self.$http.post(url, body).then((response) => {
					var resData = response.body.resData;
					if(resData.result == "1" || (resData.areaList && resData.areaList.length > 0)) {
						_self.city_list = resData.areaList;
						_self.area_list = [];
						//	_self.getArea();
					}
				});
			},
			getArea: function() {
				var _self = this;
				var cityId = $('#cityId').val();
				if(!cityId || cityId == "0") {
					cityId = _self.premises.cityId;
				}
				var body = {};
				body.params = {
					areaId: cityId
				};
				var url = _self.utilHelper.apiUrl + '/api/getArea.do';
				_self.$http.post(url, body).then((response) => {
					var resData = response.body.resData;
					if(resData.result == "1") {
						_self.area_list = resData.areaList;
					}
				});
			},
			enumList: function() {
				var _self = this;
				var body = {};
				body.params = {};
				var url = _self.utilHelper.apiUrl + '/common/getEnum/EstateTypeEnum';
				_self.$http.get(url, body).then((response) => {
					var body = response.body.data;
					_self.estate_list = body;
					_self.$nextTick(() => {
						_self.initMultiple();
					});
				});
				var url = _self.utilHelper.apiUrl + '/common/getEnum/DecorationTypeEnum';
				_self.$http.get(url, body).then((response) => {
					var body = response.body.data;
					_self.decoration_list = body;
				});
				var url = _self.utilHelper.apiUrl + '/common/getEnum/AbroadBuildingTypeEnum';
				_self.$http.get(url, body).then((response) => {
					var body = response.body.data;
					_self.buildingType_list = body;
					var selectedList = [];
					$.each(body, function(val, name) {
						selectedList.push(val);
					});
					_self.$nextTick(() => {
						_self.initMultiple();
					});
				});
			},
			//上传户型图
			uploadHouseType: function() {
				$("#addUploadModal").modal("show");
			},
			//接收上传的户型信息
			saveUploadReturn: function(data) {
				this.houseTypeList.push(data);
				this.imgViewer("houseTypeImg");
			},
			//通过下标删除户型信息
			deletefile: function(index) {
				this.houseTypeList.splice(index, 1);
				this.imgViewer("houseTypeImg");
			},
			//功能执行完后初始化图片预览
			imgViewer: function(id) {
				this.$nextTick(() => {
					$('#' + id).viewer();
				})
			},
			//创建文件对象
			onFileChange(e) {
				var files = e.target.files || e.dataTransfer.files;
				if(!files.length)
					return;
                var size = files[0].size;
                if(size > 3145728){
                    layer.msg("图片大小不能超过3M");
                    return;
                }
				var alt = e.target.alt;
				this.createImage(files[0], alt);
			},
			createImage(file, alt) {
				var _self = this;
				var reader = new FileReader();
				reader.readAsDataURL(file);
				reader.onload = function(e) {
					_self.ajaxfile(e.target.result, alt);
				};
			},
			//将base64转换blob
			dataURLtoBlob(dataUrl) {
				var arr = dataUrl.split(','),
					mime = arr[0].match(/:(.*?);/)[1],
					bstr = atob(arr[1]),
					n = bstr.length,
					u8arr = new Uint8Array(n);
				while(n--) {
					u8arr[n] = bstr.charCodeAt(n);
				}
				return new Blob([u8arr], {
					type: mime
				});
			},
			//上传附件
			ajaxfile(file, alt) {
				layer.load(0, {
					shade: false
				}); //弹出加载层
				var _self = this;
				var myForm = new FormData(); //创建formdata
				var blobBin = _self.dataURLtoBlob(file); //base64转换blob
				myForm.append("blobObject", blobBin); //想formData添加blob数据
				var url = _self.utilHelper.apiUrl + '/api/uploadBase64';
				_self.$http.post(url, myForm).then((response) => {
					layer.closeAll('loading'); //关闭加载层
					var data = response.body;
					if(data.result == "1") {
						if(alt != null && alt != "") {
							var img = {};
							img.isDeleted = 0;
							img.imageUrl = data.resData.imgName;
							img.imageType = alt;
							var index = -1;
							if(alt == 60 || alt == 90) {
								for(var i = 0; i < _self.licenseList.length; i++) {
									if(_self.licenseList[i].imageType == alt) {
										index = i;
										break;
									}
								}
							}
							if(index != -1) {
								_self.licenseList[index].imageUrl = img.imageUrl;
							} else {
								_self.licenseList.push(img);
							}
						} else {
							_self.premises.url = data.resData.imgName;
							_self.premises.urlBase64 = file;
							this.imgViewer("fmImg");
						}
						this.clearImageCache();
					} else {
						layer.msg("图片上传失败，请重试");
					}
				}, (response) => {
					layer.msg(response);
				});
			},
			handleImageAdded: function(file, Editor, cursorLocation) {
				var _self = this;
				var formData = new FormData(); //创建formdata
				formData.append("blobObject", file);
				var myForm = new FormData(); //创建formdata
				myForm.append("blobObject", file); //想formData添加blob数据
				var url = _self.utilHelper.apiUrl + '/api/uploadBase64';
				_self.$http.post(url, myForm).then((response) => {
					layer.closeAll('loading'); //关闭加载层
					var data = response.body;
					if(data.result == "1") {
						let url = data.resData.imgName;
						Editor.insertEmbed(cursorLocation, 'image', url);
					} else {
						layer.msg("图片上传失败，请重试");
					}
				}, (response) => {
					layer.msg(response);
				});
			},
			//切换佣金模式
			commissionType() {
				if(this.commissionRadio == "1") {
					this.disabledAmount = false;
					this.disabledRate = true;
					this.premises.commissionRate = null;
				} else if(this.commissionRadio == "2") {
					this.disabledAmount = true;
					this.disabledRate = false;
					this.premises.commission = null;
				}
			},
			goBack() {
				this.$router.replace({
					path: '/premises'
				})
			},
			savePremises() {
				var _self = this;
				//校验字段
				var flag = _self.verification();
				if(!flag) {
					return false;
				}
				if(_self.repeatPremisesNameFlag) {
					layer.msg('已存在同名楼盘：'+_self.premisesNames+',请修改');
					return false;
				}
				_self.btnShow = false;
				var url = _self.utilHelper.apiUrl + '/api/addPremises';
				_self.$http.post(url, _self.setParams()).then((response) => {
					var resData = response.body.resData;
					if(resData.result == "1") {
						layer.msg("保存成功", {
							time: 1500
						}, function() {
							_self.goBack();
						});
					} else {
						_self.btnShow = true;
						layer.msg("保存失败");
					}
				}, (response) => {
					_self.btnShow = true;
					layer.msg(response);
				});
			},
			//组装待提交字段
			setParams() {
				var _self = this;
				var body = {};
				let estateType = $("#estateType").multipleSelect("getSelects");
				let buildingType = $("#buildingType").multipleSelect("getSelects");
				let baseCodeValue = $("#baseCodeValue").multipleSelect("getSelects");
				let commission = _self.commissionList;
                let averagePrice = '';
                if(_self.beginPrice ){
                    averagePrice += _self.beginPrice + ',';
                }
                if(_self.endPrice){
                    if(averagePrice.charAt(averagePrice.length-1) == ','){
                        averagePrice += _self.endPrice;
                    }else{
                        averagePrice += ',' + _self.endPrice;
                    }
                }
				body.params = {
					buildingType: buildingType.join(","),
					codeName: baseCodeValue.join(","),
					name: _self.premises.name,
					provinceId: _self.premises.provinceId,
					cityId: _self.premises.cityId,
					areaId: _self.premises.areaId,
					estateType: estateType.join(","),
					decorationType: _self.premises.decorationType,
					plotRatio: _self.premises.plotRatio,
					greeningRate: _self.premises.greeningRate,
					propertyCompany: _self.premises.propertyCompany,
					propertyCharges: _self.premises.propertyCharges,
					propertyAddr: _self.premises.propertyAddr,
					buildingCompany: _self.premises.buildingCompany,
					averagePrice: averagePrice,
					rightYears: _self.premises.rightYears,
					saleStatus: _self.premises.saleStatus,
					saleAddr: _self.premises.saleAddr,
					commissionWay: _self.premises.commissionWay,
					commission: JSON.stringify(commission),
					commissionRate: _self.premises.commissionRate,
					reward: _self.premises.reward,
					dealAward: _self.premises.dealAward,
					specialTime: _self.premises.specialTime,
					visitProtect: _self.premises.visitProtect,
					saveDays: _self.premises.saveDays,
					manager: _self.premises.manager,
					mobile: _self.premises.mobile,
					discount: _self.premises.discount,
					feature: _self.premises.feature,
					cooperationRule: _self.premises.cooperationRule,
					selling: _self.premises.selling,
					customer: _self.premises.customer,
					premisesAddress: _self.premises.premisesAddress,
					saleSkill: _self.premises.saleSkill,
					reportTemp: _self.premises.reportTemp,
					introduction: _self.premises.introduction,
					url: _self.premises.url,
					panoramicView: _self.premises.panoramicView,
					projectCodeM2: _self.m2Premises.projectCode,
					//sequence: _self.premises.sequence,
					//设置开盘日期
					openingDate: this.utils.dateFormat(_self.premises.openingTime, "yyyy-MM-dd"),
					//设置入住日期
					checkInDate: this.utils.dateFormat(_self.premises.checkInTime, "yyyy-MM-dd"),
					//设置合作开始有效期
					cooperationBeginDate: this.utils.dateFormat(_self.premises.cooperationBeginTime, "yyyy-MM-dd"),
					//设置合作结束有效期
					cooperationEndDate: this.utils.dateFormat(_self.premises.cooperationEndTime, "yyyy-MM-dd"),
					//获取户型信息
					hxtInfo: JSON.stringify(_self.houseTypeList),
					dealType: _self.dealType == "现金奖" ? 2 : 1,
					//楼盘相册
					premisesImages: _self.premieseImagesToArray(),
					//规划户数
					houseHolds: _self.premises.houseHolds,
					//地上车位数
					upCarPort: _self.premises.upCarPort,
					//地下车位数
					downCarPort: _self.premises.downCarPort,
					//报备保护时间单位
					visitProtect: '天' == _self.visitProtectType ? _self.premises.visitProtect * 1440 : _self.premises.visitProtect,
					visitProtectType: '天' == _self.visitProtectType ? 1 : 3,
					//证照
					licenseImages: JSON.stringify(_self.licenseList),
					//公司名称
					corporateName: _self.premises.corporateName,
					//公司简介
					corporateDesc: _self.premises.corporateDesc
				}
				return body;
			},
			verificationCommission() {
				let format = document.getElementById('set_format_id')
				let money = document.getElementById('set_money_id')
				var moneyReg = /^\+?[1-9][0-9]*(\.\d{1,2})?$/
				var rateReg = /^(0|([1-9]\d)|(100))(\.\d{0,2})?$/
				if(!format.value) {
					layer.msg("方案名称不能为空!");
					return false;
				}
				if(!money.value) {
					layer.msg("佣金不能为空!");
					return false;
				}
				if(money.value) {
					var moneyValue = money.value;
					if(this.checkedMoney) {
						if(moneyValue && (moneyValue.length > 10 || !moneyReg.test(moneyValue))) {
							layer.msg("佣金金额格式错误，长度限制为10，保留两位小数");
							return false;
						}
					} else {
						if((moneyValue > 100 || moneyValue < 0.01)) {
							layer.msg("佣金比例范围: 0.01 ~ 100.00");
							return false;
						}
					}
				}
				return true;
			},
			verification() {
				var numberReg = /^[1-9][0-9]*$/;
				var dealAwardReg = /^\d{0,6}$/;
				if(!this.premises.name) {
					layer.msg("请输入楼盘名称!");
					return false;
				}
				if(!this.premises.provinceId) {
					layer.msg("请选择省份!");
					return false;
				}
				if(!this.premises.cityId) {
					layer.msg("请选择城市!");
					return false;
				}
				if(!this.premises.areaId) {
					layer.msg("请选择区域!");
					return false;
				}
				let estateType = $("#estateType").multipleSelect("getSelects");
				if(estateType.length == 0) {
					layer.msg("请选择物业类型!");
					return false;
				}
				let buildingType = $("#buildingType").multipleSelect("getSelects");
				if(buildingType.length == 0) {
					layer.msg("请选择建筑类别!");
					return false;
				}
				if(!this.premises.decorationType) {
					layer.msg("请选择装修状况!");
					return false;
				}
				if(!this.premises.name) {
					layer.msg("请输入楼盘名称!");
					return false;
				}
				if(!this.premises.commissionWay) {
					layer.msg("结佣方式不能为空!");
					return;
				}
				if(!this.premises.propertyCharges) {
					layer.msg("请输入物业费!");
					return false;
				}
				var chargeReg = /^[0-9]+(.[0-9]{1,3})?$/;
				if(!this.beginPrice && !this.endPrice) {
					layer.msg("请输入均价!");
					return false;
				}
				//均价区间判断
				if(this.beginPrice && this.endPrice){
				    if(parseFloat(this.beginPrice) > parseFloat(this.endPrice)){
				        layer.msg("均价区间填写错误");
				        return false;
					}
				}
				// if(!chargeReg.test(this.premises.averagePrice)) {
				// 	layer.msg("均价格式错误!");
				// 	return false;
				// }
				if(!this.premises.premisesAddress) {
					layer.msg("请输入楼盘地址!");
					return false;
				}
				if(this.premises.reward && !numberReg.test(this.premises.reward)) {
					layer.msg("请输入正确的带看奖励,只能为整数!");
					return false;
				}
				if(this.premises.dealAward && !dealAwardReg.test(this.premises.dealAward)) {
					layer.msg("成交奖格式错误,请输入0~999999范围内的整数");
					return false;
				}
				if(!this.premises.visitProtect) {
					layer.msg("请输入报备保护时间");
					return false;
				}
				if(this.premises.visitProtect && !numberReg.test(this.premises.visitProtect)) {
					layer.msg("请输入正确的报备保护时间，只能为整数!");
					return false;
				}
				if(!this.premises.specialTime) {
					layer.msg("请输入特殊报备间隔!");
					return false;
				}
				if(!numberReg.test(this.premises.specialTime)) {
					layer.msg("请输入正确的特殊报备间隔，只能为整数!");
					return false;
				}
				if(this.premises.saveDays && !numberReg.test(this.premises.saveDays)) {
					layer.msg("请输入正确的流程等待时间,只能为整数!");
					return false;
				}
				if(!this.premises.manager) {
					layer.msg("请输入项目经理!");
					return false;
				}
				if(!this.premises.mobile) {
					layer.msg("请输入联系方式!");
					return false;
				}
                if(!(/^1(1|2|3|4|5|7|8|9)\d{9}$/.test(this.premises.mobile))){
                    layer.msg("手机号码有误，请重填");
                    return false;
                }

                var openTime = this.premises.openingTime;
				var checkInTime = this.premises.checkInTime;
//				if(!openTime) {
//					layer.msg("请输入开盘日期!");
//					return false;
//				}
//				if(!checkInTime) {
//					layer.msg("请输入入住日期!");
//					return false;
//				}
				if(openTime && checkInTime) {
					var openTimeDate = new Date(openTime);
					var checkInTimeDate = new Date(checkInTime);
					//开盘日期 - 入住日期
					var diff = Date.parse(openTimeDate) - Date.parse(checkInTimeDate);
					if(diff >= 0) {
						layer.msg("入住日期必须大于开盘日期!");
						return false;
					}
				}
				if(this.premises.cooperationBeginTime && this.premises.cooperationEndTime) {
					var cooperationBeginTimeDate = new Date(this.premises.cooperationBeginTime);
					var cooperationEndTimeDate = new Date(this.premises.cooperationEndTime);
					//开盘日期 - 入住日期
					var diff = Date.parse(cooperationBeginTimeDate) - Date.parse(cooperationEndTimeDate);
					if(diff >= 0) {
						layer.msg("合作有效期起止日期必须大于终止日期!");
						return false;
					}
				}
				var panoramicView = this.premises.panoramicView;
				if(panoramicView) {
					var urlReg = /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
					if(!urlReg.test(panoramicView)) {
						layer.msg("全景看房,请输入正确的网址!");
						return false;
					}
				}
				var houseTypeList = this.houseTypeList;
				if(houseTypeList.length <= 0) {
					layer.msg("请填写可售户型");
					return false;
				}
//				if(this.premises.sequence && !numberReg.test(this.premises.sequence)) {
//					layer.msg("请输入正确的排列顺序,只能为整数!");
//					return false;
//				}
				return true;
			},
			//验证手机号码是否正确
			verifyingMobile() {
				var _self = this;
				_self.mobileFlag = false;
				var body = {};
				body.params = {
					mobile: _self.premises.mobile
				};
				var url = _self.utilHelper.apiUrl + '/api/verifyingMobile.do';
				_self.$http.get(url, body).then((response) => {
					var body = response.body;
					if(body.result == "1") {
						if(body.flag == "1") {
							_self.mobileFlag = true;
						} else {
							layer.msg("手机号格式错误!");
						}
					}
				});
			},
			//从M2系统同步楼盘
			chooseM2Premises() {
				this.premisesByM2Flag = 'T';
				$("#addChooseM2").modal("show");
			},
			saveChooseM2Return(premisesByM2) {
				this.m2Premises.projectCode = premisesByM2.projectCode;
				this.m2Premises.projectName = premisesByM2.projectName;
				this.premises.name = premisesByM2.projectName;
				this.premisesByM2Flag = 'F';
			},
			//校验同步的楼盘名称是否被修改，并提示用户
			verifyingPremisesName() {
				var _self = this;
				//校验楼盘名称是否已存在
				this.checkPremisesName();
				//当projectName为空时，表示未同步,不进行校验
				if(_self.m2Premises.projectName == "") {
					return false;
				}
				//当项目名称相同时，不进行校验
				if(_self.m2Premises.projectName == this.premises.name) {
					return false;
				}
				layer.confirm('从M2同步的楼盘信息已被修改，是否放弃同步？', {
					skin: 'layui-layer-DarkOrange', //样式类名
					btn: ['是', '否']
				}, function() {
					_self.m2Premises = {
						projectCode: '',
						projectName: '',
					}
					layer.closeAll('dialog');
				}, function() {
					_self.premises.name = _self.m2Premises.projectName;
				});
			},
			checkPremisesName () {
				var _self = this;
				let body = {};
				body.params = {premisesName: this.premises.name};
				var url = _self.utilHelper.apiUrl + '/api/checkPremisesName';
				_self.$http.post(url, body).then((response) => {
					var resData = response.body.resData;
					if(resData.result == "1") {
						if(resData.premisesNames) {
							this.repeatPremisesNameFlag = true;
							this.premisesNames = resData.premisesNames;
						} else {
							this.repeatPremisesNameFlag = false;
							this.premisesNames = '';
						}
					} else {
						this.repeatPremisesNameFlag = false;
						this.premisesNames = '';
						console.log(resData.errMsg)
					}
				}, (response) => {
					layer.msg(response);
				});
			},
			openUploadImage() {
				$("#uploadPremisesImageModal").modal("show");
				this.$refs.premisesImageInit.premisesImageInit();
			},
			savePremisesImgReturn(data) {
				// 新增的楼盘相册
				var _self = this;
				var type = 0;
				if(data.length > 0) {
					type = data[0].imageType;
					//显示样式
					$(".presentation").removeClass("active");
					$(".tab-pane").removeClass("active");
					$(".tab-pane").removeClass("in");
					$("#p" + type).addClass("active");
					$("#" + type).addClass("active");
					$("#" + type).addClass("in");
					if(_self.premisesImages[type]) {
						_self.premisesImages[type].push.apply(_self.premisesImages[type], data);
					} else {
						_self.premisesImages[type] = data.slice(0);
					}
					this.$forceUpdate();
				}
			},
			//删除楼盘相册图片
			deletePremisesImage(index, img, key) {
				var _self = this;
				_self.premisesImages[key].splice(index, 1);
				this.$forceUpdate();
			},
			premieseImagesToArray() {
				var _self = this;
				var array = [];
				for(var i in _self.premisesTypes) {
					var key = _self.premisesTypes[i];
					if(_self.premisesImages[key]) {
						array.push.apply(array, _self.premisesImages[key])
					}
				}
				return JSON.stringify(array);
			},
			showImgCount(list) {
				if(list) {
					return list.length;
				} else {
					return 0;
				}
			},
			clearImageCache() {
				this.$refs.warrant.value = null;
				this.$refs.salePermit.value = null;
				this.$refs.distributorContract.value = null;
				this.$refs.businessLicense.value = null;
			},
            textImageUpload(e){
                var _self = this;
                var files = e.target.files || e.dataTransfer.files;
                if(files[0].size > 3145728){
                    layer.msg('图片太大，请上传小于2M的图片');
                    return;
                }
                var lod = layer.load(0, {shade: [0.1,'#000']}); //弹出加载层
                var myForm = new FormData(); //创建formdata
                myForm.append("blobObject", files[0]); //想formData添加blob数据
                var url = _self.utilHelper.apiUrl + '/api/uploadBase64';
                _self.$http.post(url, myForm).then((response) => {
                    layer.closeAll('loading'); //关闭加载层
                    var data = response.body;
                    if(data.result == "1") {
                        let url = data.resData.imgName;
                        let length = _self.quill.getSelection().index;
                        _self.quill.insertEmbed(length, 'image', url);
                        // 调整光标到最后
                        _self.quill.setSelection(length + 1);
                    } else {
                        layer.msg("图片上传失败，请重试");
                    }
                    document.getElementById("iviewUp").value = '';
                    layer.close(lod);
                }, (response) => {
                    layer.msg(response);
                    layer.close(lod);
                });
            }

		}
	}
</script>